<?php if (!defined('CORE_DIR')) die('Wrong entry point!');

/* 
 * Copyright 2010 Anton Muraviev a.k.a kuromaisu
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

Aero::define('UriLibrarySpecification', AS_SINGLETON);

Aero::import('libs/uri');

/*
 * UriLibrarySpecification
 */
class UriLibrarySpecification extends AeroSpec
{
	protected function itShouldBeAbleToCreateURIFromStringsAndArrays()
	{
		// Usual array
		$uri = AeroUri::make('some/segment',array('just','some','values'),array('key0' => 'value0','key1' => 'value1','key2' => 'value2'));
		
		$this->variable($uri)->equals('/some/segment/just,some,values/key0/value0/key1/value1/key2/value2');
	}
	
	protected function itShouldBeAbleToRewriteAnyURLBackAndForth()
	{
		$from = '/test_request/rewrite/123/something-awesome';
		$to = 'test_request/something-awesome/123';
		
		$this->value(AeroUri::rewrite($from))->equals($to);
		$this->value(AeroUri::make($to))->equals($from);
	}
}